Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/prismjs

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/prismjs

TypeScript definitions for prismjs

  • 1.26.5
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • ts5.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @types/prismjs?

@types/prismjs provides TypeScript type definitions for the PrismJS library, which is a lightweight, extensible syntax highlighter. These type definitions help developers use PrismJS in TypeScript projects by providing type safety and IntelliSense support.

What are @types/prismjs's main functionalities?

Syntax Highlighting

This feature allows you to highlight code syntax for a given language. The example shows how to highlight JavaScript code.

const code = `const foo = 'bar';`;
const highlightedCode = Prism.highlight(code, Prism.languages.javascript, 'javascript');
console.log(highlightedCode);

Custom Language Definition

This feature allows you to define custom languages for syntax highlighting. The example shows how to define a simple custom language with keywords and numbers.

Prism.languages.myLanguage = {
  'keyword': /\b(?:if|else|for|while)\b/,
  'number': /\b\d+\b/
};
const code = `if 123 else`;
const highlightedCode = Prism.highlight(code, Prism.languages.myLanguage, 'myLanguage');
console.log(highlightedCode);

Plugins

PrismJS supports various plugins to extend its functionality. The example shows how to configure the autoloader plugin to load languages from a custom path.

Prism.plugins.autoloader.languages_path = 'https://example.com/prism-languages/';
Prism.highlightAll();

Other packages similar to @types/prismjs

FAQs

Package last updated on 23 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc